let login = require('../../utils/login');
let $api = require('../../config');
Page({
	data:{
		 userInfo:{},
		 aboutText:''
	},
	onReady(){
		this.checkLogin();
		this.aboutTextFuc();
	},
	/*分享*/
  onShareAppMessage: function (res) {
		let id = wx.getStorageSync('userInfo').user_id;
		if (res.from === 'button') {
			return {
				title: '股票估值查询',
				path: `/pages/index/index?shareId=${id}`,
				imageUrl:'../../images/share-img.png'
			}
		}else{
			return {
				title: '股票估值查询',
				path: `/pages/index/index?shareId=${id}`,
				imageUrl:'../../images/share-img.png'
			}
		}
  },
	/*用户永续授权*/
	login(res){
		/*用户允许授权*/
		let self = this;
		if(res.detail.userInfo){
			login.Login((res)=>{
				let data = JSON.parse(res.message)
				wx.setStorageSync('userInfo',data.data);
				self.setData({ 
					userInfo:data.data
				})
			})
		}
	},
	/*查看是否授权*/
  checkLogin(){
        let self = this;
        wx.getSetting({
			success: function(res){
				/*用户授权*/
				if (res.authSetting['scope.userInfo']) {
						self.setData({ 
							userInfo:wx.getStorageSync('userInfo')
						})
				}else{
				
				}
			}
        })
    },
	aboutTextFuc(){
        let token = wx.getStorageSync('userInfo').token;
        let self = this;
        wx.request({
            url:$api.api.other,
            method:'GET',
            data: {
                token
            },
            header: {
                'content-type': 'application/json'
            },
            success: function(res) {
                let aboutText = res.data.data.about
                self.setData({
                    aboutText:aboutText
                })
            }
        })
	}
})